<?php

class Menu
{
	var $connDB;

	function draw($gruppo, &$menuPrincipale, &$tooltip, &$link, &$voce, &$menuPrincipaleId, &$voceId)
	{
		$this->connDB->SetFetchMode(ADODB_FETCH_NUM);
		
		$sql = "SELECT men.ute_descrizione, men.ute_tooltip, men.ute_parametri, men.ute_modulo_id, mod.ute_mod, mod.ute_do,
					   men.ute_menu_id, men.ute_voce
  				  FROM ute_menu_gruppi AS mgr
					   LEFT JOIN ute_menu AS men ON (men.ute_menu_id = mgr.ute_menu_id AND men.ute_voce = mgr.ute_voce)
					   LEFT JOIN ute_moduli AS mod ON (mod.ute_modulo_id = men.ute_modulo_id)
 				 WHERE mgr.ute_gruppo_id = $gruppo";
		
		$rs = $this->connDB->Execute($sql);
		if ( ! $rs ) {
			print 'Error Menu draw: '.$this->connDB->ErrorMsg().'<BR>';
			exit;
		}

		$menuCnt = -1;
		$vociCnt = -1;
		while ( $arr = $rs->FetchRow() )
		{
			if ( $arr[3] == "" )
			{
				$menuCnt++;
				$menuPrincipaleId[ $menuCnt ] = sprintf("%02s",$arr[6]);
				$menuPrincipale[ $menuCnt ] = $arr[0];
				$vociCnt = -1;
			}
			else
			{
				$vociCnt++;
				$voceId[ $menuCnt ][ $vociCnt ] = sprintf("%02s%02s",$arr[6], $arr[7]);
				$voce[ $menuCnt ][ $vociCnt ] = $arr[0];
				$tooltip[ $menuCnt ][ $vociCnt ] = $arr[1];
				$link[ $menuCnt ][ $vociCnt ] = "Main.php?mod=".$arr[4]."&do=".$arr[5].$arr[2];
			}			
		}
	}
}

?>